package com.jt.controller;

import com.jt.pojo.User;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller //SpringMVC专门扫描的注解
public class HelloController {

    @RequestMapping("/hello")
    @ResponseBody   //返回值JSON串
    public String hello(){
        //字符串返回本身
        return "您好SpringMVC";
    }
    @RequestMapping("/getUser")
    @ResponseBody //{"id":"101","name":"SpringMVC!!"}
    public User getUser(){
        User user = new User();
        user.setId(101);
        user.setName("SpringMVC!!");
        //如果是对象则返回JSON
        return user;
    }

}
